package tour.spring.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 

@Controller
@RequestMapping("/main/ajax")
public class AjaxController {

    @RequestMapping(value = "/add.html", method = RequestMethod.GET)
    public String getAjaxAddPage() {
     return "/ajaxPage";
 }
  
    @RequestMapping(value = "/add.html", method = RequestMethod.POST)
    public @ResponseBody Integer add(@RequestParam(value="inputNumber1", required=true) Integer inputNumber1,
           @RequestParam(value="inputNumber2", required=true) Integer inputNumber2,
           Model model) {
  
    	return inputNumber1 + inputNumber2;
 }
}